/**
 * 系统主界面
 */
Ext.define('Jason.view.main.Viewport', {
    extend: 'Ext.container.Viewport',
    xtype: 'mainviewport',

    requires: [
        'Ext.list.Tree',
        'Ext.toolbar.Spacer',
		'Jason.view.main.ViewportController',
		'Jason.view.main.MainContainerWrap',
		'Jason.view.main.ViewportModel',
		'Jason.view.protal.dashboard.Dashboard',
		'Ext.toolbar.Breadcrumb',
        'Jason.store.ReqUrl',
        'Jason.view.main.Empty',
		'Wys.view.ArticlList'
    ],

    controller: 'mainviewport',
    viewModel: {
        type: 'mainviewport'
    },

    cls: 'sencha-dash-viewport',
    itemId: 'mainView',

    layout: {
        type: 'vbox',
        align: 'stretch'
    },

    listeners: {
        render: 'onMainViewRender'
    },

    items: [
        {
            xtype: 'toolbar',
            cls: 'sencha-dash-dash-headerbar toolbar-btn-shadow',
            height: 64,
            itemId: 'headerBar',
            items: [
                {
                    xtype: 'component',
                    reference: 'senchaLogo',
                    cls: 'sencha-logo',
                    html: '<div class="main-logo"><img src="resources/images/sencha-icon.png">'+cfg.systemname+'</div>',
                    width: 250
                },
                {
                    margin: '0 0 0 8',
                    cls: 'delete-focus-bg',
                    iconCls:'x-fa fa-outdent',
                    id: 'main-navigation-btn',
                    handler: 'onToggleNavigationSize'
                },
                {
                    xtype: 'tbspacer',
                    flex: 1
                },
//                {xtype:'label',text:'小'},
//                {
//                	xtype: 'sliderfield',
//                    width: 100,
//                    publishOnComplete: false
//                },
//                {xtype:'label',text:'大'},
                {
                    cls: 'delete-focus-bg',
                    iconCls:'x-fa fa-search',
                    hrefTarget: '_self',
					handler : 'onLocalSearch',
                    tooltip: '点击进行搜索'
                },{
					xtype : 'textfield',
					hidden:true,
					cls : 'notHaveBottomBorder_cls',
					ui : 'notHaveBottomBorder',
					itemId : 'localSearchInput',
					emptyText : '站内搜索'
				},{
					cls : 'delete-focus-bg',
					iconCls : 'fa fa-question-circle',
					href : '#fqa',
					tooltip : '使用文档'
				},{
                	xtype: 'button',
                	cls: 'delete-focus-bg',
                	iconCls: 'x-fa fa-th-large',
                	tooltip: '系统皮肤',
                	menu:[
                		{text : '系统默认',code : 'triton',listeners : {click:'onChangeTheme'}},
                		{text : '传统Ext',code : 'classic',listeners : {click:'onChangeTheme'}},
                		{text : '黑色主题',code : 'gray',listeners : {click:'onChangeTheme'}},
                		{text : '蓝色主题',code : 'neptune',listeners : {click:'onChangeTheme'}}
                	],
                	reference:'b_style'
                },{
                	xtype : 'skinSelect'
                },{
					cls : 'delete-focus-bg',
					iconCls : 'fa fa-arrows-alt',
					tooltip : '开启全屏',
					handler : 'onEnabledFullScreen'
				},{
					cls : 'delete-focus-bg',
					iconCls : 'fa fa-wechat',
					hidden:!(session.get('enableIM') === "true"),
					tooltip : '内部通讯系统',
					handler : function(){
						var chat = Ext.ComponentQuery.query('chatView');
						if(chat.length==0){
							Ext.create('Jason.view.chat.MainView');
						}else{
							chat[0].show();
						}
					}		
				},{
                    cls: 'delete-focus-bg',
					xtype : 'tipNumButton',
					num : 12,
					handler: 'onShowNotice',
                    iconCls:'x-fa fa-bell'
                },{
					cls : 'delete-focus-bg',
					iconCls : 'fa fa-cog',
					handler : 'onShowSetting'
				},{
                    xtype: 'image',
                    cls: 'header-right-profile-image',
                    height: 35,
                    width: 35,
                    alt:'current user image',
                    src: 'resources/images/user-profile/defaults.png'
                },{
                    xtype: 'tbtext',
                    bind: '{userName}',
                    cls: 'top-user-name'
                }
            ]
        },
        {
            xtype: 'maincontainerwrap',
            id: 'main-view-detail-wrap',
            reference: 'mainContainerWrap',
            flex: 1,
            items: [
                {
                    xtype: 'treelist',
                    reference: 'navigationTreeList',
                    itemId: 'navigationTreeList',
                    ui: 'navigation',
                    store: 'NavigationTree',
                    width: 250,
                    expanderFirst: false,
                    expanderOnly: false,
					singleExpand: true,
                    listeners: {
                        selectionchange: 'onNavigationTreeSelectionChange'
                    }
                },
                {
					/*xtype : 'container',
					flex: 1,
					items : [{
						xtype : 'breadcrumb',
						hidden : cfg.showNavigation,
						style : 'background:#fff',
						useSplitButtons: true,
						enableFocusableContainer: true,
						rootVisible: true,
						height : 38,
						store: 'NavigationTree',
					},{*/
						xtype: 'panel',
						flex: 1,
						reference: 'mainCardPanel',
						cls: 'sencha-dash-right-main-container',
						itemId: 'contentPanel',
						bodyStyle: 'background:#f5f5f5;',
						dockedItems: [{
					        xtype: 'toolbar',
					        dock: 'top',
					        items: [{
					            xtype : 'breadcrumb',
								hidden : !cfg.showNavigation,
					            showIcons: false,
					            bind: {
			                        selection: '{selectedNodeByBreadcrumb}'
			                    },
								style : 'background:#fff',
								useSplitButtons: true,
								enableFocusableContainer: false,
								allowFocusingDisabledChildren:true,
								rootVisible: true,
								store: 'NavigationTree'
					        }]
					    }],
						layout: {
							type: 'card',
							anchor: '100%'
						}
					/*},{
						xtype : 'container',
						height : 48,
						hidden:cfg.showCopyRight,
						flex:1,
						html : cfg.copyRight
					}]*/
				}
            ]
        }
    ]
});
